import cv2
import numpy as np
image=cv2.imread('weiqi.png')
cv2.imshow("Input",image)
img_copy=image.copy()
blur_copy=cv2.medianBlur(img_copy,5)
gray=cv2.cvtColor(blur_copy,cv2.COLOR_BGR2GRAY)
binary=cv2.Canny(gray,50,150)
lines=cv2.HoughLines(binary,1,np.pi/180,150)
for line in lines:
    rho,theta=line[0]
    a=np.cos(theta)
    b=np.sin(theta)
    x0,y0=a*rho,b*rho
    pt1=(int(x0+1000*(-b)),int(y0+1000*a))
    pt2=(int(x0-1000*(-b)),int(y0-1000*a))
    cv2.line(image,pt1,pt2,(0,0,255),2)
cv2.imshow("HoughLines",image)
cv2.waitKey()
cv2.destroyAllWindows()